#include "CHowToPlayState.h"
#include "CMainMenuState.h"
#include "CGame.h"

#include "SGD Wrappers/CSGD_DirectInput.h"

CHowToPlayState::CHowToPlayState(void)
{
	m_nIndex = 0;

	m_nCursorID = -1;

	m_BMFonts.SetImageID(CSGD_TextureManager::GetInstance()->LoadTexture("resources/graphics/AnG_bitmapfont.png", D3DXCOLOR(0,255,0,255)));
	m_BMFonts.SetCharWidth(8);
	m_BMFonts.SetCharHeight(9);
	m_BMFonts.SetCol(16);
	m_BMFonts.SetStartChar('@');
}
CHowToPlayState::~CHowToPlayState(void)
{

}

CHowToPlayState* CHowToPlayState::GetInstance(void)
{
	static CHowToPlayState instance;
	return &instance;
}
void CHowToPlayState::Enter()
{
	m_pD3D	=	CSGD_Direct3D::GetInstance();
	m_pTM	=	CSGD_TextureManager::GetInstance();
	m_pDS	=	CSGD_DirectSound::GetInstance();
	m_pWM	=	CSGD_WaveManager::GetInstance();

	m_nCursorID = m_pTM->LoadTexture("resources/graphics/SGD_MenuCursor.png", D3DCOLOR_XRGB(255, 255, 255));

}
bool CHowToPlayState::Input()
{
	CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();

	if(pDI->KeyPressed(DIK_UPARROW))
	{
		if(--m_nIndex < 0)
			m_nIndex = 0;
	}
	else if(pDI->KeyPressed(DIK_DOWNARROW))
		if(++m_nIndex > 0)
			m_nIndex = 0;

	if(pDI->KeyPressed(DIK_RETURN))
	{
		if(m_nIndex == 0)
			CGame::GetInstance()->ChangeState(CMainMenuState::GetInstance());
	}

	return false;
}
void CHowToPlayState::Update(float fElapsedTime)
{
}
void CHowToPlayState::Render(void)
{
	CSGD_Direct3D* pD3D = CSGD_Direct3D::GetInstance();

	pD3D->Clear(0, 0, 0);
	pD3D->DeviceBegin();

	pD3D->SpriteBegin();

	CSGD_TextureManager::GetInstance()->Draw(m_nCursorID, 80,100 + (m_nIndex * 50)); //, 4.0f, 4.0f, NULL, 64.0f, 65.0f, 0, D3DCOLOR_ARGB(128, 255, 0, 0));
	m_BMFonts.Draw("EXIT", 100,100, 1.0f, D3DXCOLOR(255,255,255,255));



	pD3D->SpriteEnd();

	pD3D->DeviceEnd();
	//pD3D->DrawText("BGM Volume", 100, 100);


	//pD3D->DrawText("SFX Volume", 100, 150);


	//pD3D->DrawText("Exit",100,200);

	pD3D->Present();
}
void CHowToPlayState::Exit(void)
{
}